/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package homework6;

/**
 *
 * @author Administrator
 */
import java.util.*;

class Student2 {

    public String Name;
    public int Score;

    public Student2(String name) {
        Name = name;
    }

    public void getScore(int score) {
        Score = score;
    }
}

public class MainE {

    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        Student2 std[] = new Student2[11];
        int i, s;
        String n;
        for (i = 1; i < 11; i++) {
            n = reader.next();
            std[i] = new Student2(n);
        }
        for (i = 1; i < 11; i++) {
            s = reader.nextInt();
            std[i].getScore(s);
        }
        for (int j = 1; j < 10; j++) {
            for (i = 1; i < 10; i++) {
                if (std[i].Name.compareTo(std[i + 1].Name) > 0) {
                    std[0] = std[i];
                    std[i] = std[i + 1];
                    std[i + 1] = std[0];
                }
            }
        }
        for (i = 1; i < 11; i++) {
            System.out.println(std[i].Name + "," + std[i].Score);
        }
    }
}
